package com.ruoyi.algorithm.repository;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.algorithm.entity.TableStruct;
import com.ruoyi.algorithm.mapper.TableStructMapper;
import com.beihu.sightplus.common.repository.BaseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 */
@Service
public class TableStructRepository extends BaseRepository<TableStructMapper, TableStruct> {

    @Autowired
    TableStructMapper tableStructMapper;

    /**
     * 根据表名获取表结构列表
     *
     * @param tableName 表明
     * @param fieldKey  字段名
     * @return 表结构列表
     */
    public List<TableStruct> getByTableName(String tableName, String fieldKey) {
        return tableStructMapper.selectList(Wrappers.lambdaQuery(TableStruct.class)
                .select(TableStruct::getId, TableStruct::getFieldKey, TableStruct::getFieldName, TableStruct::getIsExactMatching)
                .eq(TableStruct::getTableName, tableName)
                .eq(TableStruct::getFieldKey, fieldKey));
    }

    /**
     * 根据表名获取表结构列表
     *
     * @param tableName 表明
     * @return 表结构列表
     */
    public List<TableStruct> getByTableName(String tableName) {
        return tableStructMapper.selectList(Wrappers.lambdaQuery(TableStruct.class)
                .select(TableStruct::getId, TableStruct::getFieldKey, TableStruct::getFieldName, TableStruct::getIsExactMatching)
                .eq(TableStruct::getTableName, tableName)
        );
    }
}




